<?php if (!defined('BASEPATH')) exit('No direct script access allowed');?>
<!DOCTYPE html>
<html>
<head>
<title>注册账号</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<meta name="keywords" content="">
<meta name="description" content="">
<link rel="shortcut icon" href="<?php echo base_url()?>statics/resources/images/favicon.ico" />
<link href="<?php echo base_url()?>statics/resources/style/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?php echo base_url()?>statics/resources/js/jquery.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>statics/resources/js/jquery.i18n.properties-1.0.9.js" ></script>
<script type="text/javascript" src="<?php echo base_url()?>statics/resources/js/jquery-ui-1.10.3.custom.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>statics/resources/js/jquery.validate.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>statics/resources/js/md5.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>statics/resources/js/page_regist.js?lang=zh"></script>
<!--[if IE]>
  <script src="<?php echo base_url()?>statics/resources/js/html5.js"></script>
<![endif]-->
<!--[if lte IE 6]>
	<script src="<?php echo base_url()?>statics/resources/js/DD_belatedPNG_0.0.8a-min.js" language="javascript"></script>
	<script>
	  DD_belatedPNG.fix('div,li,a,h3,span,img,.png_bg,ul,input,dd,dt');
	</script>
<![endif]-->
</head>
<body class="loginbody">
<div class="dataEye">
	<div class="loginbox registbox">
		
		<div class="login-content reg-content">
			<div class="loginbox-title">
				<h3 style="text-align:center;">注册</h3>
			</div>
			<form id="signupForm">
			<div class="login-error"></div>
			<div class="row">
				<label class="field" for="user-name">账户名（必填）</label>
				<input type="text" value="" class="input-text-user noPic input-click" name="user-name" id="user-name">
			</div>
			<div class="row">
				<label class="field" for="password">设置密码（必填）</label>
				<input type="password" value="" class="input-text-password noPic input-click" name="password" id="password">
			</div>
			<div class="row">
				<label class="field" for="confirm-password">确认密码（必填）</label>
				<input type="password" value="" class="input-text-password noPic input-click" name="confirm-password" id="confirm-password">
			</div>
			<div class="row">
				<label class="field" for="company">姓名/企业名称（必填）</label>
				<input type="text" value="" class="input-text-user noPic input-click" name="company" id="company">
			</div>			
			<div class="row">
				<label class="field" for="phone">手机号（必填）</label>
				<input type="text" value="" class="input-text-user noPic input-click" name="phone" id="phone">
			</div>
			<div class="row">
				<label class="field" for="weixin">微信号</label>
				<input type="text" value="" class="input-text-user noPic input-click" name="weixin" id="weixin">
			</div>
			<div class="row">
				<label class="field" for="reason">申请原因（必填）</label>
				<input type="text" value="" class="input-text-user noPic input-click" name="reason" id="reason">
			</div>
			<div class="row tips">
				<input type="checkbox" id="checkBox">
				<label>
				我已阅读并同意
				<a href="#">隐私政策、服务条款</a>
				</label>
			</div>
			<div class="row" style="color:red; font-size:15px; margin-top:12px; line-height:20px; display:none;" id="loginerror"></div>
			<div class="row btnArea">
				<a class="login-btn" id="submit" onClick="Login()">注册</a>
			</div>
			</form>
		</div>
		<div class="go-regist">
			已有帐号,请<a href="<?php echo base_url()?>" class="link">登录</a>
		</div>
	</div>
	

</div>
<div class="loading">
	<div class="mask">
		<div class="loading-img">
		<img src="<?php echo base_url()?>statics/resources/images/loading.gif" width="31" height="31">
		</div>
	</div>
</div>
</body>
</html>
<script>
function Login() {
	if (! $("#signupForm").valid()) {
        return;
     }


	$.ajax({
		type: "POST",
		url: "<?php echo site_url('register/add');?>",
		data: {
			username: $('#user-name').val(),
			password: $('#password').val(),
			confirmpassword: $('#confirm-password').val(),
			company: $('#company').val(),
			phone: $('#phone').val(),
			weixin: $('#weixin').val(),
			reason: $('#reason').val()
		},
		//dataType: "json",
		success: function (data) {

			if (data==1) {
				$(".login-error").text("恭喜你！注册成功！").show();
				setTimeout("location.href='<?php echo site_url('login')?>'",2000);
			} else {
				$(".login-error").text(data).show();			
			}
			
			//$('.loading').hide();
			//location.href = "<?php echo site_url('home/index')?>";
			return false;
		},
		timeout: 60000,
		error: function (xhr, status) {
			if (status == "timeout") {
				$(".login-error").text("您的网络好像很糟糕，请刷新页面重试").show();
				return false;
			}
			else {
				$(".login-error").text("服务器内部错误，请重试").show();
				return false;
			}
		}
	});
	return false;
}
</script>
